﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WF_AuditorReplace_Guide.aspx.vb"
    Inherits="MyWorkflow.WF_AuditorReplace_Guide" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title></title>
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    <link href="/_common/styles/global.css" type="text/css" rel="stylesheet">
    <link href="/_forms/styles/form.css" type="text/css" rel="stylesheet">

    <script language="javascript" src="/_common/scripts/global.js"></script>

    <script language="javascript" src="/_controls/setting.js"></script>

    <script language="javascript" src="/_controls/util/util.js"></script>

    <script language="javascript" src="/_controls/lookup/lookup.js"></script>

    <script language="javascript" src="/_controls/lookup/LookupDialogs.js"></script>

    <script language="javascript" src="/_forms/FormBase.js"></script>

    <script language="javascript" src="Workflow_Mini.js"></script>

    <script language="javascript" src="SelectUsers.js"></script>
    <script language="javascript" type="text/javascript">
        var mode = "";
        var _cUserBUGUID = "";
        function win_onload() {
            //模板重置责任人显示责任人类型
            mode = $id("__mode").value;
            if (mode == "") parent.window.close();
            if (mode == "Module") {
                $id("trNotice").style.display = "inline";
            }
            _cUserBUGUID = $id("__BUGUID").value;
            $id("txtOldAuditorName").value = $id("__oldAuditorName").value;
        }
        function oprReturn() {
            if ($id("txtNewAuditorName").value == "") {
                alert("请选择新责任人！");
                return;
            }
            if ($id("txtNewAuditorGUID").value == $id("__oldAuditorGUID").value) {
                alert("新责任人不能和原责任人相同，请重新选择！");
                return;
            }
            if (mode == "Module" && GetAuditorType() == 0) {
                alert("请选择责任人角色！");
                return;
            }
            var XML = new StringBuilder();
            XML.append("<HandleResult ");
            XML.append("newAuditorName ='");
            XML.append(XmlEncode($id("txtNewAuditorName").value));
            XML.append("' newAuditorGUID='");
            XML.append($id("txtNewAuditorGUID").value);
            if (mode == "Module") {
                XML.append("' AuditorType='");
                XML.append(GetAuditorType());
            }
            XML.append("' >");
            XML.append("</HandleResult>");
            parent.window.returnValue = XML.toString();
            parent.window.close();
        }
        
        //选择责任人
        function SelectAuditor(o) {

            var sUrl = "/MyWorkflow/Interface/Pub/SelectUserSingle.aspx";
            var params = "ShowDisabledUser=0&BUGUID=" + _cUserBUGUID;
            var sHeight = "500px";
            var sWidth = "520px";
            //注意此处使用的父窗口来弹出模态对话框。模态对话框上再弹出模态对话框可能会造成SESSION丢失。
            var returnValue = window.dialogArguments.openMyDlg("选择责任人", sUrl, params, window.dialogArguments, sWidth, sHeight);
            if (typeof returnValue == "object" && returnValue.items.length > 0) {
                $id(o.valueid).value = returnValue.items[0].id;
                $id(o.textid).value = returnValue.items[0].name;
            }
        }

        //获取责任人类型，未选择返回0否则返回|值
        function GetAuditorType() {
            var AuditorType = 0;
            if ($id("chkStep").checked) {
                AuditorType = 1;
            }
            if ($id("chkCC").checked) {
                AuditorType = AuditorType == 0 ? 2 : AuditorType | 2;
            }
            if ($id("chkBook").checked) {
                AuditorType = AuditorType == 0 ? 4 : AuditorType | 4;
            }
            if ($id("chkWatch").checked) {
                AuditorType = AuditorType == 0 ? 8 : AuditorType | 8;
            }
            return AuditorType;
        }
    </script>
</head>
<body ms_positioning="GridLayout" onload="win_onload()">
    <form id="Form1" method="post" runat="server">
    <table height="100%" cellspacing="0" cellpadding="0" width="100%">
        <tr>
            <td class="header">
                <div class="header" id="divHead">
                    重置责任人</div>
                <br>
            </td>
        </tr>
        <tr>
            <td class="main">
                <table height="100%" cellspacing="0" cellpadding="0" width="100%">
                    <colgroup>
                        <col width="5">
                        <col width="65">
                        <col>
                    </colgroup>
                    <tr height="20">
                        <td colspan="3">
                        </td>
                    </tr>
                    <tr id="trHandleText">
                        <td>
                        </td>
                        <td id="tdHandleText" style="height: 25px" valign="top" class="req">
                            原责任人</td>
                        <td><input type="text" class="ro" id="txtOldAuditorName" />
                    </tr>
                    <tr id="trAssignUser" height="25">
                        <td>
                        </td>
                        <td class="req">
                            新责任人</td>
                        <td>
                            <table style="table-layout: fixed" cellspacing="0" cellpadding="0" width="100%">
                                <colgroup>
                                    <col>
                                    <col width="25">
                                </colgroup>
                                <tr>
                                    <td>
                                        <input type="text" readonly="readonly" id="txtNewAuditorName" />
                                    </td>
                                    <td style="padding-left: 4px">
                                        <img class="lookup" id="imgAssign" onclick="SelectAuditor(this)" src="../../_imgs/btn_off_lookup.gif"
                                            align="absMiddle" valueid="txtNewAuditorGUID" textid="txtNewAuditorName" maxuserlength="5"
                                            ismultiselect="true">
                                    </td>
                                </tr>
                            </table>
                            <input type="hidden" id="txtNewAuditorGUID"/>
                        </td>
                    </tr>
                    <tr height="16">
                    <td colspan="3">
                    </td>
                    </tr>
                    <tr id="trNotice" style="display:none">
                        <td>
                            &nbsp;</td>
                        <td colspan="2">
                            <table id="tbAuditorType" style="table-layout: fixed; height="100%" cellspacing="0" cellpadding="0" width="100%">
                                <tr height="25">
                                    <td class="req">
                                        责任人角色：</td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr height="25">
                                    <td style=" white-space:nowrap">
                                        <input id="chkStep" type="checkbox" checked /><label for="chkStep">步骤责任人（审批、会签） </label>
                                    </td>
                                    <td  style=" white-space:nowrap">
                                        <input id="chkCC" type="checkbox" checked /><label for="chkCC">抄送人 </label>
                                    </td>
                                </tr>
                                <tr height="25">
                                    <td style=" white-space:nowrap">
                                        <input id="chkBook" type="checkbox" checked /><label for="chkBook">流程归档人 </label>
                                    </td>
                                    <td style=" white-space:nowrap">
                                        <input id="chkWatch" type="checkbox" checked /><label for="chkWatch">流程监控人 </label>
                                    </td>
                                </tr>
                            </table> 
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td id="tdAlert" style="color: red" colspan="2">
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr height="40">
            <td class="buttons">
                <button id="btnSubmit" onclick="oprReturn()" type="button">
                    确 定</button>&nbsp;&nbsp;
                <button onclick="parent.window.close();" type="button">
                    取 消</button>
            </td>
        </tr>
    </table>
    <asp:Literal ID="lScript" runat="server"></asp:Literal>
    </form>
</body>
</html>
